package com.venutech.gongan.dao;

import com.baomidou.mybatisplus.plugins.Page;
import com.venutech.gongan.dto.CountByStatusDTO;
import com.venutech.gongan.dto.WorkCountByTypeAndStatusDTO;
import com.venutech.gongan.entity.TbOpWorkOrder;
import com.venutech.gongan.entity.Work;
import com.venutech.gongan.vo.Operation;
import com.venutech.gongan.vo.WorkDto;
import com.venutech.gongan.vo.WorkExtDto;
import com.venutech.gongan.vo.WorkInfoDto;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 工单
 */
public interface WorkMapper {
     //工单添加
    int insert(Work work);

    //根据ID返回对象
    Work getById(Integer wk_id);

    //分页查询所有信息
    List<Work> getInfo(String begintime, String endtime, Page<WorkInfoDto> page, @Param("wk_type") Integer wk_type, @Param("poleName") String poleName, @Param("workStatus") Integer workStatus);

    List<Work> getPatrolWorkInfo(String begintime, String endtime, Page<WorkInfoDto> page, @Param("wk_type") Integer wk_type, @Param("poleName") String poleName, @Param("workStatus") Integer workStatus);

    //我的工单==》历史查询
    List<Work> getInfo2(String begintime, String endtime, Page<Work> page, @Param("wk_type") Integer wk_type, @Param("user_id") Integer user_id);

    //我的工单==》待审批查询
    List<Work> getInfo3(String begintime, String endtime, Page<Work> page, @Param("wk_type") Integer wk_type, @Param("user_id") Integer user_id);

    //查询所有工单Excel导出
    List<Work> getAllWorks(@Param("user_id") Integer userId, @Param("wk_type") Integer wk_type);

    //API
    //工单添加Api
    int insertWorkDto(WorkDto work);
    //外网工单添加Dto
    int insertWorkExtDto(WorkExtDto workExtDto);

    //查询用户提交的工单信息
    List<Work> getWorkDtoList(@Param("wk_sq_user_id") Integer userId, @Param("wk_type") Integer workType,
                              @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<Work> getWorkDtoListByPage(@Param("wk_sq_user_id") Integer userId, @Param("wk_type") Integer workType, Page<Work> page);

    //巡检打卡
    int poleWorkDto(WorkDto work);

    //查询今日工单报表数据-Count
    Integer getSelCountByDay();

    Integer getTotalCount();

    //查詢我的当天工单
    Integer getSelCountByUser(@Param("user_id") Integer user_id);

    //查询我的所有工单
    Integer getTotalCountByUser(@Param("user_id") Integer user_id);

    //根据当前用户查询本周工单报表数据-导出Excel
    List<Work> getSelByWeek(@Param("user_id") Integer user_id);

    //查询本周工单报表数据-Count
    Integer getSelCountByWeek(@Param("user_id") Integer user_id);

    //根据当前用户查询本月工单报表数据-导出Excel
    List<Work> getSelByMonth(@Param("user_id") Integer user_id);

    //查询本月工单报表数据-Count
    Integer getSelCountByMonth(@Param("user_id") Integer user_id);

    Integer getCountByTypeAndDay(@Param("workType") int workType, @Param("startDay") Date startDay);

    Integer getCountByType(@Param("workType") int workType);

    List<Work> getByTypeAndDateRegion(@Param("workType") int workType, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
    /**
     * @author:
     * date: 2021/12/3 0003 15:30
     * @since: JDK 1.8
     * @description: 未绑定的设备数量
     * @param:
     * @return:
     */
    int getSelectUnBindCount();

    /**
     *
     * @param v
     * @return
     */
    int insertOperation(Operation v);

    List<Operation> selectOperationList(Page<Operation> page, @Param("work_device_type") Integer work_device_type);

    Operation getOperationById(Operation v);

    List<Work> getWorkByUserid(@Param("userId") Integer userId, @Param("sTime") String sTime, @Param("eTime") String eTime);

    int approveWork(@Param("workId") Integer workId, @Param("spUserId") Integer spUserId);

    int approveVideoSpWork(@Param("workState") Integer workState, @Param("nextWorkSpUserId") Integer nextWorkSpUserId, @Param("workId") Integer workId);

    int declineVideoSpWork(@Param("spUserId") Integer spUserId, @Param("workId") Integer workId);

    int updateSpUser(@Param("workId") Integer workId, @Param("spUserId") Integer spUserId);

    // 杆件对应的未处理工单列表
    List<Work> getUnhandledWorkListByPoleId(@Param("poleId") Integer poleId);

    int updateWork(@Param("workId") Integer workId, @Param("user_id") Integer user_id);

    List<Work> getUserWorkByTypeAndStatus(@Param("workType") Integer workType, @Param("workStatus") Integer workStatus, @Param("userId") Integer userId);

    Work selectWorkByTbOpWorkOrder(TbOpWorkOrder tbOpWorkOrder);

    int updateWorkByOp(Work work);

    /**
     * 根据类型和状态统计
     * @return
     */
    List<WorkCountByTypeAndStatusDTO> countByTypeAndStatus();

    List<CountByStatusDTO> countByStatus();
}
